home *** CD-ROM | disk | FTP | other *** search
Wrap
/***************************************************************************************** Snippet: SampleRateAvail Description: This snippet checks for the number of sample rates available on a given Mac and lists those rates. Programmer: Kevin Mellander Organization: Apple Computer, Inc. Department Developer Technical Support, DTS Language/Envir. MPW C version 3.3.1 Date Created 11/29/94 *****************************************************************************************/ #include <SoundInput.h> #include <ToolUtils.h> #include <Types.h> #include <stdio.h> struct soundRateData{ short numberOfRatesSupported; Handle ratesSupported; } soundRateInfo; void main() { OSErr soundErr = 0; long mySIRefNum; short setSoundMeterState = 1; Fixed *myFixedPointer; Fixed myFixedVariable; register unsigned long loopCounter; soundRateInfo.numberOfRatesSupported = 0; soundRateInfo.ratesSupported = nil; //Open the sound input device soundErr = SPBOpenDevice("\p",siWritePermission,&mySIRefNum); if (soundErr != noErr) { DebugStr("\p Failure at call to SPBOpenDevice."); ExitToShell(); } //Get the number of rates supported soundErr = SPBGetDeviceInfo(mySIRefNum,siSampleRateAvailable,(Ptr) &soundRateInfo); if (soundErr != noErr) DebugStr("\p Failure at call to SPBSetDeviceInfo set to 0"); else printf("The number of sample rates supported by this recording device is %d \n \n And the sample rates supported are: \n", soundRateInfo.numberOfRatesSupported); //Now parse our list of sample rates to determine which are supported myFixedPointer = (Fixed *)(*(soundRateInfo.ratesSupported)) ; for(loopCounter=0; loopCounter < soundRateInfo.numberOfRatesSupported; loopCounter++) { myFixedVariable = *myFixedPointer; switch (myFixedVariable) { case 0xAC440000: printf("\t44.1 kHz\n"); break; case 0x56EE8BA3: printf("\t22.254 kHz\n"); break; case 0x56220000: printf("\t22.050 kHz\n"); break; case 0x2B7745D1: printf("\t11.127 kHz\n"); break; case 0x2B110000: printf("\t11.025 kHz\n"); break; case 0x1CFA2E8B: printf("\t7.418 kHz\n"); break; case 0x15BBA2E8: printf("\t5.563 kHz\n"); break; default: printf("I do not have a listing for this sample rate\n"); } myFixedPointer++; } //We're done so close the device soundErr = SPBCloseDevice(mySIRefNum); if (soundErr != noErr) DebugStr("\p Failure at call to SPBCloseDevice"); }